package bo

import "github.com/tebeka/selenium"

type NodeInf interface {
	GetNode() *Node
}

// Node 公共节点
type Node struct {
	ID                 string
	Name               string
	Type               int
	BeforeExec         int
	BeforeExecIsRandom bool
}

func (n *Node) GetNode() *Node {
	return n
}

// OpenPageNode 打开页面节点
type OpenPageNode struct {
	Node          `mapstructure:",squash"`
	URL           string
	RetryTimes    int
	RetryInterval int
	Timeout       int
}

// ClickElementNode 点击元素节点
type ClickElementNode struct {
	Node     `mapstructure:",squash"`
	Xpath    string
	IsPaging bool
	Ele      selenium.WebElement
}

// ExtractDataNode 提取数据节点
type ExtractDataNode struct {
	Node     `mapstructure:",squash"`
	Xpath    string
	DataType int
	Data     []struct {
		Name string
		Type int
		// {type:xxx,param:xxx}
		Reprocess []any
	}
	Ele selenium.WebElement
}

// LoopNode 循环节点
type LoopNode struct {
	Node         `mapstructure:",squash"`
	LoopType     int
	SubNodes     []any
	XpathList    []string
	IsLoopPaging bool
	URLs         []string
	LoopTimes    int
}

// ConditionNode 条件节点
type ConditionNode struct {
	Node     `mapstructure:",squash"`
	SubNodes []any
	Ele      selenium.WebElement
}

// BranchNode 分支节点
type BranchNode struct {
	Node          `mapstructure:",squash"`
	ConditionType int
	Pattern       string
	SubNodes      []any
	Ele           selenium.WebElement
}

// TaskExec 执行任务请求
type TaskExec struct {
	TaskId        int64
	DataFieldList []string
	Nodes         []any
}
